package net.gz01.wallet.web.controller.admin;

import java.io.File;

import com.jfinal.kit.StrKit;

import net.gz01.wallet.web.controller.BaseController;
import net.gz01.wallet.web.service.ReportService;

public class ReportController extends BaseController {
	public void reportPage() {
		render("clearing/report/reportList.html");
	}

	public void download() {
		String settleDateStart = getPara("settleDateStart");
		String settleDateEnd = getPara("settleDateEnd");
		String reportType = getPara("reportType");
		if ("virtualBalance".equals(reportType) == false && (StrKit.isBlank(settleDateStart) || StrKit.isBlank(settleDateEnd))) {
			renderFail("起止日切日期必填！");
			return;
		}
		ReportService reportService = new ReportService();
		File file = null;
		if ("income".equals(reportType)) {
			file = reportService.income(settleDateStart, settleDateEnd);
		} else if ("share".equals(reportType)) {
			file = reportService.share(settleDateStart, settleDateEnd);
		} else if ("tradedetail".equals(reportType)) {
			file = reportService.tradeDetail(settleDateStart, settleDateEnd);
		} else if ("epaylinks".equals(reportType)) {
			file = reportService.epaylinksPayOrders(settleDateStart, settleDateEnd);
		} else {
			file = reportService.virtualBalance_youli();
		}
		if (file == null) {
			renderFail("没有满足条件的数据");
		} else {
			renderFile(file);
		}
	}

}
